//
//  JMEnrollmentPolicyViewMode.m
//  VoluntaryStar
//
//  Created by xiaorui on 15/9/6.
//  Copyright (c) 2015年 ios. All rights reserved.
//

#import "JMEnrollmentPolicyViewMode.h"
#import "JMAppNetworkClient.h"
#import "JMPolicyMode.h"



@interface JMEnrollmentPolicyViewMode ()

+(NSMutableArray *)dataModel:(NSArray *)array;

@end

@implementation JMEnrollmentPolicyViewMode

+ (void) fetchEnrollmentPolicyListParametes:(NSDictionary *)dict  block:(ReturnBackMessage)block{
    [JMAppNetworkClient enrollmentPolicyListWithInfo:dict complete:^(id data, NSError *error) {
        NSMutableDictionary *downDict = (NSMutableDictionary *)data;
        if([[downDict objectForKey:@"status"] integerValue] == 1){
            NSMutableArray *array = [JMEnrollmentPolicyViewMode dataModel:data[@"list"]];
            block(data,error,array);
        }else{
            block(data,error,nil);
        }
    }];
}
+(NSMutableArray *)dataModel:(NSArray *)array{
    NSMutableArray *mArray = [[NSMutableArray alloc]initWithCapacity:0];
    for(int i = 0; i <array.count;i++){
        NSDictionary *dict = array [i];
        JMPolicyMode *mode = [[JMPolicyMode alloc]init];
        mode.titleString =dict[@"name"];
        mode.logoString = dict[@"logo"];
        mode.policyString = dict[@"policy"];
        mode.levelString = dict[@"level"];
        mode.policyId = [dict[@"id"] intValue];
        [mArray addObject:mode];
    }
    return mArray;
    
}

@end
